package br.ufrj.ppgi.infovis.mtgraph;

import java.util.Stack;

class GraphNodeStack {
	//Inclui No na pilha
	static void showpush(Stack<GraphNode> st, GraphNode node) {
		int pos = st.search(node);
		//Verifico se o No ja esta na pilha
		if (pos < 0) {
			st.push(node);
		}
		//System.out.println("push(" + node.getComponent().getText() + ")"); 
		//System.out.println("stack: " + st); 
	} 

	//Retira No na pilha
	static GraphNode showpop(Stack<GraphNode> st) {
		if (!st.isEmpty()) { 
			//System.out.print("pop -> "); 
			GraphNode node = (GraphNode) st.pop(); 
			//System.out.println(node.getComponent().getText()); 
			//System.out.println("stack: " + st); 
			return node;
		} else {
			return null;
		}
	}
}

class GraphEdgeStack {
	//Inclui aresta na pilha
	static void showpush(Stack<GraphEdge> st, GraphEdge edge) {
		int pos = st.search(edge);
		//Verifico se a aresta ja esta na pilha
		if (pos < 0) {
			st.push(edge);
		} 
		//System.out.println("stack: " + st); 
	} 

	//Retira aresta na pilha
	static GraphEdge showpop(Stack<GraphEdge> st) {
		if (!st.isEmpty()) { 
			//System.out.print("pop -> "); 
			GraphEdge edge = (GraphEdge) st.pop(); 
			//System.out.println("stack: " + st); 
			return edge;
		} else {
			return null;
		}
	}
}